package com.cuit.washneedshake.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cuit.washneedshake.model.entity.NationalProvinces;
import com.cuit.washneedshake.service.NationalProvincesService;
import com.cuit.washneedshake.mapper.NationalProvincesMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;


@Service
public class NationalProvincesServiceImpl extends ServiceImpl<NationalProvincesMapper, NationalProvinces>
        implements NationalProvincesService {
    @Resource
    private NationalProvincesMapper nationalProvincesMapper;

    @Override
    public List<HashMap<String, Object>> getTopConfirmProvinces() {
        List<String> provinces = nationalProvincesMapper.getConfirmProvinces();
        List<Integer> numbers = nationalProvincesMapper.getConfirmNumber();

        List<HashMap<String, Object>> result = new ArrayList<>();
        for (int i = 0; i < provinces.size(); i++) {
            HashMap<String, Object> map = new HashMap<>();
            map.put("province", provinces.get(i));
            map.put("confirm", numbers.get(i));
            result.add(map);
        }
        return result;
    }

}




